package bidsanity

/*L-1: Listings have the following required fields: name, end date/time, and starting bid price (unit test)
L-2: Listings have the following optional fields: description (unit test)
L-3: Listings are required to have a seller (Customer) (unit test)
L-4: Listing descriptions must be less than 256 characters (unit test)
L-5: Listing end date/time must be in the future (unit test)
L-6: Listing name must be less than 64 characters (unit test)
L-7: Listing has a nullable field for the winner (Customer) (unit test)*/

class Listing {
    String name
    Date endDate
    double startingBidPrice
    String description
    Customer seller
    Customer winner
    static hasMany = [bids: Bid]
    Date startDate = new Date()

    static constraints = {
        name(nullllable:false, size:1..64, blank:false)
        endDate(nullable:false, min:new Date())
        startingBidPrice(nullable:false, min:0.5D)
        description(nullable:true, size:0..255)
        winner(nullable:true)
        startDate(nullable:false)
    }
}
